After Early Gains, Stock Market Ends Down